package Entity;
import FinalProject.PriceException;

public abstract class Entity_Product {
    private String id;
    private String name;
    private double price;
    private String description;

    // 构造方法（含价格校验）
    public Entity_Product(String id, String name, double price, String description) throws PriceException {
        this.id = id;
        this.name = name;
        if (price <= 0) {
            throw new PriceException("价格必须>0（当前值：" + price + "）");
        }
        this.price = price;
        this.description = description;
    }

    // 抽象方法：展示商品信息
    public abstract void displayInfo();

    // Getter方法
    public String getId() { return id; }
    public String getName() { return name; }
    public double getPrice() { return price; }
    public String getDescription() { return description; }
}